{% extends 'TopxiaWebBundle:Settings:layout.html.twig' %}

{% block title %}{{'头像'|trans}} - {{ parent() }}{% endblock %}
{% set side_nav = 'avatar' %}
{% set script_controller = 'settings/avatar' %}

{% block main %}
  {% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {class:'panel-col'} %}
    {% block heading %}{{'头像'|trans}}{% endblock %}
    {% block body %}

      {% if fromCourse %}
      <div class="alert alert-info">{{'请设置自定义头像。'|trans}}</div>
      {% endif %}

      <form id="settings-avatar-form" class="form-horizontal" method="post">

        {{ web_macro.flash_messages() }}

        <div class="form-group">
          <div class="col-md-2 control-label"><b>{{'当前头像'|trans}}</b></div>
          <div class="controls col-md-8 controls">
          	<img src="{{ filepath(user.largeAvatar, 'avatar.png') }}">
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label">
          </div>
          <div class="controls col-md-8 controls">
            {{'<p class="help-block">你可以上传JPG、GIF或PNG格式的文件，文件大小不能超过<strong>2M</strong>。</p>'|trans|raw}}
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label"></div>
          <div class="controls col-md-8 controls">
            <a id="upload-picture-btn"
            class="btn btn-primary"
            data-upload-token="{{ upload_token('tmp', 'image') }}"
            data-goto-url="{{path('settings_avatar_crop',{goto: goto})}}"
            >{{'上传新头像'|trans}}</a>
          </div>
        </div>

        {% if partnerAvatar %}
          <div class="form-group">
            <div class="col-md-2 control-label"><b>{{'论坛头像'|trans}}</b></div>
            <div class="controls col-md-8 controls">
              <img src="{{ partnerAvatar }}" class="mrm">
              <button class="btn btn-default use-partner-avatar" type="button" data-url="{{ path('settings_avatar_fetch_partner') }}" data-goto="{{ path('settings_avatar') }}" data-img-url="{{ partnerAvatar }}" >{{'使用该头像'|trans}}</button>
            </div>
          </div>
        {% endif %}

      </form>

    {% endblock %}
  {% endembed %}
{% endblock %}